#ifndef ROPEPROJECT_H
#define ROPEPROJECT_H
#include <QObject>
#include <QVariant>
#include <QEventLoop>
#include <QProcess>
#include <QAbstractSocket>
#include "Include/IRopeProject.h"

class QDomNode;
class QTcpSocket;
namespace Plugins
{
    class RopeFile;
    class RopeProject: public IRopeProject
    {
        Q_OBJECT
    friend class RopeFile;
    public:
        RopeProject();
        virtual ~RopeProject();
    public:
        virtual IRopeFile* openFile(const QString & fileName);
        virtual void closeFile(const QString & fileName);
        virtual void revalidate(const QString & path, const QString & mainScript, const QString& projectPath);
    public slots:
        void initProject(const QString & path, const QString & mainScript, const QString& projectPath);
        virtual void classNames(const QString & prefix);
    private slots:
        void readyError();
        void onProjectInited();
        void onProjectRevalidated();
        void onRunError(QProcess::ProcessError);
        void onClassList();
        void onError(QAbstractSocket::SocketError err);
    signals:
        void classListComplete(const QStringList & list);
    private:
        void makeRequest(const QString & methodName, const QVariantList & params, QObject * reciever = NULL, const char * slot = NULL);
    private:
        QProcess *_proc;
        QHash<QString, RopeFile*> _files;
        QString _ip;
        int _port;
        QEventLoop _loop;
    };
}
#endif // ROPEPROJECT_H
